-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Shared code architecture #1027
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
BobDickinson
wants to merge
21
commits into
modelcontextprotocol:main
Choose a base branch
from
BobDickinson:tui-integration-design
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Shared code architecture #1027
BobDickinson
wants to merge
21
commits into
modelcontextprotocol:main
from
BobDickinson:tui-integration-design
+11,148
−4,478
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… version, fixed problem with undetected failures (isError: true payloads).
…stry), all tests actually validate what they say they test.
… up process termination (possible leak on Windows), beefed up http server cleanup (close all connections), removed unused hasValidJsonOutput, reduced CLI timeout to give it breathing room with vitest timeout.
…pes, terminology, and usage.
…truth (all UX now reflects InspectorClient state directly for prompts, resources, tools, messages, and stdio transport log events).
…ill not actually sharing yet)
… utilize shared MCP functionality. Enhanced build scripts to include shared, upgraded React and TypeScript dependencies across all workspaces, and implemented Project References for improved type resolution and build order.
…ng direct Client usage. Removed transport-related code and updated logging level handling. Enhanced environment configuration management. Cleaned up unused imports and streamlined argument parsing.
…rations, consolidating client logic and removing deprecated client utility files. Updated argument parsing and logging configurations, ensuring consistent behavior across CLI and TUI. Enhanced documentation to reflect changes in architecture and functionality.
…r, enabling cross-platform event handling for both browser and Node.js. Update related documentation and React hook to utilize new event system, ensuring compatibility and improved state management across TUI and web clients.
…. The shared package is now built before the CLI, ensuring proper dependencies are in place. This change enhances the build process and maintains consistency across the project.
Contributor
Author
|
Another element that I probably should have implemented in this PR is that we can now build a comprehensive test suite around the shared InspectorClient that will provide very good coverage of the functional elements of the Inspector, so that all we really need to test in the TUI or web client is the UX part. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This draft PR introduces a shared code architecture that enables code reuse across the MCP Inspector's CLI, TUI, and web client interfaces. This addresses the feature drift and maintenance burden caused by the CLI and web client maintaining separate implementations, with immediate code sharing across the CLI and TUI, and planned support for the web client (v2).
What's Included
1. TUI Integration
mcp-inspectas a first-class workspacemcp-inspector --tuiflag2. Shared Package (
@modelcontextprotocol/inspector-shared)InspectorClient- a comprehensive wrapper around the MCP SDKClientthat manages:EventTarget(cross-platform compatible)3. CLI Migration
InspectorClientfrom shared packageInspectorClientmethodscli/src/client/directory, etc)4. Shared React Code
useInspectorClienthook for reactive state managementEventTargetevents and provides reactive React stateArchitecture
The shared package includes:
shared/mcp/- MCP client/server interaction (InspectorClient, transport creation, config loading)shared/react/- Shared React code (hooks, components, etc.)shared/json/- JSON utilities for parameter conversionshared/test/- Test fixtures and harness serversBoth CLI and TUI now use the same
InspectorClientimplementation, ensuring consistent behavior and eliminating code duplication (both apps are now thin UX-only implementations).Next Steps
Phase 4: TUI Feature Gap Implementation (Planned)
InspectorClientInspectorClientfor v2 web client integrationInspectorClientwill be very close to ready for full v2 web client supportPhase 5: v2 Web Client Integration (Planned)
InspectorClientwith the v2 web client once Phase 4 is complete and v2 web client is readyInspectorClientand other shared code as required to support v2 while maintaining CLI and TUI compatabilityDocumentation
See
docs/shared-code-architecture.md(included in this PR) for:InspectorClientcapabilities and APITesting
This is a draft PR for review. Feedback welcome on the architecture and integration approach.